#include "xlog.h"
#include "ph_hashmap.h"

void f(void);

int main(int argc, char ** argv)
{
	xlog(" this is dict ");

	f();

	return 0;
}

const char * tks[] =
{
        "name",
        "age",
        "#314",
        "#628",
        "#658505728",

        0,
};

void
f()
{
	int rc = HM_OK;

	hm_t * hm = hm_create0(0, HM_K_COPY | HM_V_COPY, 0);

	rc = hm_put_str(hm, "name", "jswang");
	rc = hm_put_str(hm, "age", "29");
	rc = hm_put_str(hm, "identify", "9527");

	hm_print(hm);

	{
	    char buf[128];
	    int i = 314;
	    for (; i > 0; i <<= 1) {
	        sprintf(buf, "#%d", i);
	        rc = hm_put_str(hm, buf, buf);
	    }
	}

	hm_print(hm);

	{
	    xlog(" ------------------------- ");
	    const char ** k = 0;
	    const char * v = 0;
	    for (k = tks; *k; ++k) {
	        rc = hm_get_str(hm, *k, &v);
	        xlog("k:%s \t -- v:%s", *k, v);
	    }

	    xlog(" ------------------------- ");
	    *k = "name";
	    rc = hm_put_str(hm, *k, "rex");
	    rc = hm_get_str(hm, *k, &v);
	    xlog("k:%s \t -- v:%s", *k, v);

	    xlog(" ------------------------- ");
	    *k = "age";
	    rc = hm_del_str(hm, *k, &v);
	    xlog("hm_del_str return %d with v:%s", rc, v);
	    rc = hm_get_str(hm, *k, &v);
	    xlog("hm_get_str return %d", rc);
	}

	rc = hm_release(hm);
}
